import { useUserStoreWidthOut } from '@/stores/user';

const useOrgAuth = () => {
  const userStore = useUserStoreWidthOut();
  const checkedOrg: any = computed(() => {
    if (!userStore.getOrgInfo.orgId) {
      return {};
    }
    return Object.assign(
      {},
      (userStore?.getAuth ?? [])
        .filter((item: any) =>
          (item.appList || []).some((el: any) => el.appCode === 'CTMS')
        )
        .find((item: any) => item.orgId === userStore.getOrgInfo.orgId) || {}
    );
  });
  return {
    checkedOrg,
  };
};

export default useOrgAuth;
